<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style type="text/css">
			* {
				margin: 0;
				padding: 0;
			}

			#myCan {
				display: block;
				margin: 0 auto;
				background-color: lightskyblue;
			}
		</style>
	</head>
	<body>
		<canvas id="myCan" width="400" height="400"></canvas>
		<script type="text/javascript">
			var oC = document.getElementById('myCan');
			var ctx = oC.getContext('2d');
			ctx.fillStyle = 'red'; 
			// ctx.globalAlpha = 0.5; //设置透明度
		
			ctx.fillRect(100,100,100,100);
			// destination-over
			ctx.save();
			ctx.globalCompositeOperation = 'xor';
			ctx.fillStyle = 'green';
			ctx.arc(200,200,60,0,2*Math.PI);
			ctx.fill();
			ctx.restore();
		</script>
	</body>
</html>
